package org.example.io.handler.client;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.example.io.protocol.packet.LoginResponsePacket;
import org.example.io.util.LoginUtil;

@Slf4j
public class LoginResponsePacketHandler extends SimpleChannelInboundHandler<LoginResponsePacket> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, LoginResponsePacket msg) throws Exception {
        if (msg.isSuccess()) {
            log.info("客户端登录成功：{}", msg.isSuccess());
            LoginUtil.markAsLogin(ctx.channel());
        } else {
            log.info("客户端登录失败，原因：{}", msg.getMessage());
        }
    }
}
